import 'package:flutter/material.dart';
import 'package:get/state_manager.dart';
import 'package:x_builder/base/status.dart';
import 'base_viewmodel.dart';

///@date:  2025/1/22
///@author:  leisiyu
///@description:
abstract class BaseView<T extends BaseViewModel> extends GetView<T> {

  const BaseView({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx((){
      switch(controller.status.value){
        case Status.init:
          return const SizedBox();
        case Status.loading:
          return buildLoadingWidget(context);
        case Status.loaded:
          return buildWidget(context);
        case Status.error:
          return buildErrorWidget(context);
      }
    });
  }
  ///加载中
  Widget buildLoadingWidget(BuildContext context);

  ///加载完成
  Widget buildWidget(BuildContext context);

  ///加载失败
  Widget buildErrorWidget(BuildContext context);
}